
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE- 2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
  <HEAD>
    <TITLE>Apache FtpServer - FAQ</TITLE>
    <META http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <LINK type="text/css" rel="stylesheet" href="http://mina.apache.org/index.data/style.css">
    <SCRIPT type="text/javascript" language="javascript">
      function init() {
        /* Search form initialization */
        var form = document.forms['googleSearch'];
        if (form != null) {
          form.elements['domains'].value = location.hostname;
          form.elements['sitesearch'].value = location.hostname;
        }

      }
    </SCRIPT>
  </HEAD>
  <BODY onload="init()">
    <DIV id="PageContent" style="padding-bottom: 0px;">
      <DIV class="pageheader" style="padding: 6px 0px 0px 0px;">
        <DIV id="apacheLogo" style="width: 100%; text-align: right; position: absolute; top: 33px;">
          <A href="http://www.apache.org/"><IMG src="http://www.apache.org/images/asf-logo.gif" border="0" alt="The Apache Software Foundation" title="The Apache Software Foundation" hspace="12"></A>
        </DIV>
        <DIV id="minaLogo" style="position: absolute; top: 24px; left: 16px;">
          <A href="http://mina.apache.org/ftpserver"><IMG src="http://mina.apache.org/ftpserver/index.data/logo-300x95.png" border="0" alt="Apache FtpServer" title="Apache FtpServer"></A>
        </DIV>
        <DIV class="greynavbar" style="margin: 156px 0px 0px 0px;">
          <TABLE border="0" cellpadding="2" cellspacing="0" width="100%" style="position: relative; z-index: 10;">
            <TR>
              <TD align="left" valign="middle" align="left" style="padding-left: 17px;" width="100%" nowrap="">
                &nbsp;<A href="index.html" title="Apache MINA FtpServer">Apache MINA FtpServer</A>&nbsp;&gt;&nbsp;<A href="index.html" title="Index">Index</A>&nbsp;&gt;&nbsp;<A href="" title="FAQ">FAQ</A>
              </TD>
              <TD align="right" valign="middle" nowrap="">
                <FORM name="googleSearch" action="http://www.google.com/search" method="get" style="margin: 0px; padding: 0px;">
                  <INPUT type="hidden" name="ie" value="UTF-8">
                  <INPUT type="hidden" name="oe" value="UTF-8">
                  <INPUT type="hidden" name="domains" value="">
                  <INPUT type="hidden" name="sitesearch" value="">
                  <INPUT type="text" name="q" maxlength="255" value="">        
                  <INPUT type="submit" name="btnG" value="Google Search">
                </FORM>
              </TD>
              <TD align="right" valign="middle" style="padding-right: 8px;" nowrap="">
                <FORM name="listSearch" action="http://mina.markmail.org/search/" method="get" style="margin: 0px; padding: 0px;">
                  <INPUT type="text" name="q" maxlength="255" value="">        
                  <INPUT type="submit" value="Mailing List Search">
                </FORM>
              </TD>
            </TR> 
          </TABLE>
        </DIV>
      </DIV>
      <DIV id="pageBody" style="clear: both;">
        <TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
          <TR>
            <TD width="192" valign="top" nowrap="">
              <DIV style="padding: 0px 8px 16px 20px;">
                
                                                                                                                                                                                                                                          <H3><A name="Navigation-Overview"></A>Overview</H3>

<UL>
	<LI><A href="index.html" title="Index">Home</A></LI>
	<LI><A href="features.html" title="Features">Features</A></LI>
	<LI><A href="documentation.html" title="Documentation">Documentation</A></LI>
	<LI><A href="downloads.html" title="Downloads">Downloads</A></LI>
	<LI><A href="source.html" title="Source">Source</A></LI>
	<LI><A href="" title="FAQ">FAQ</A></LI>
	<LI><A href="related-projects.html" title="Related Projects">Related Projects</A></LI>
</UL>


<H3><A name="Navigation-Community"></A>Community</H3>

<UL>
	<LI><A href="mailing-lists.html" title="Mailing Lists">Mailing Lists</A></LI>
	<LI><A href="getting-involved.html" title="Getting Involved">Getting Involved</A></LI>
	<LI><A href="reporting-a-bug.html" title="Reporting a Bug">Reporting a Bug</A></LI>
	<LI><A href="contributors.html" title="Contributors">Contributors</A></LI>
	<LI><A href="testimonials.html" title="Testimonials">Testimonials</A></LI>
</UL>


<H3><A name="Navigation-Sponsorship"></A>Sponsorship</H3>

<UL>
	<LI><A href="http://www.apache.org/foundation/thanks.html" rel="nofollow">Thanks</A></LI>
	<LI><A href="http://www.apache.org/foundation/sponsorship.html" rel="nofollow">Sponsorship</A></LI>
	<LI><A href="http://www.apache.org/foundation/contributing.html" rel="nofollow">Contributing</A></LI>
</UL>
                                                                                                                    </DIV>
             <DIV align="center"><IFRAME src="http://www.apache.org/ads/buttonbar.html" style="border-width:0" frameborder="0" scrolling="no" width="135" height="265"></IFRAME></DIV>
            </TD>
            <TD width="100%" valign="top">
              <DIV class="pagecontent">
                <H1 style="margin-top: 0px;">
                  FAQ
                </H1>
                <DIV class="wiki-content">
                  <H2><A name="FAQ-General"></A>General</H2>

<DIV>
<UL>
    <LI><A href="#FAQ-General">General</A></LI>
<UL>
    <LI><A href="#FAQ-Myserverfailswithjava.net.SocketException%253AToomanyfilesopen">My server fails with java.net.SocketException: Too many files open</A></LI>
<UL>
    <LI><A href="#FAQ-ChangethetimeoutinWindows">Change the timeout in Windows</A></LI>
    <LI><A href="#FAQ-ChangethetimeoutinLinux">Change the timeout in Linux</A></LI>
</UL>
    <LI><A href="#FAQ-HowcanIaddotherlanguagetranslations%253F">How can I add other language translations?</A></LI>
    <LI><A href="#FAQ-HowcanIsendbinarydatastoredinadatabasewhentheFTPServergetstheRETRcommand%253F">How can I send binary data stored in a database when the FTP Server gets the RETR command?</A></LI>
    <LI><A href="#FAQ-WhyIamgettingClassNotFoundExceptionwhenIamtryingtousedatabasebasedusermanager%253F">Why I am getting ClassNotFoundException when I am trying to use database based user manager?</A></LI>
    <LI><A href="#FAQ-IhaveupdatedtheJDKversion.AfterthattheLDAPusermanagerisnotworking.">I have updated the JDK version. After that the LDAP user manager is not working.</A></LI>
</UL>
</UL></DIV>

<H3><A name="FAQ-Myserverfailswithjava.net.SocketException%3AToomanyfilesopen"></A>My server fails with java.net.SocketException: Too many files open</H3>
<P>Network sockets are treated like files and your operating system has a limit to the number of file handles it can manage. Running out of file handles is usually due to a large number of clients connecting and disconnecting frequently. As specified by TCP, after being closed sockets remain in the TIME_WAIT state for some additional time. The reason is to ensure that delayed packets arrive on the correct socket. In Windows, the default TIME_WAIT timeout is 4 minutes, in Linux it is 60 seconds. </P>

<H4><A name="FAQ-ChangethetimeoutinWindows"></A>Change the timeout in Windows</H4>
<OL>
	<LI>Run regedit to start the Registry Editor</LI>
	<LI>Locate the following key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\tcpip\Parameters</LI>
	<LI>Add a new value named TcpTimedWaitDelay asa  decimal and set the desired timeout in seconds (30-300)</LI>
	<LI>Reboot</LI>
</OL>


<H4><A name="FAQ-ChangethetimeoutinLinux"></A>Change the timeout in Linux</H4>
<OL>
	<LI>Update the configuration value by running (30 seconds used in the example)
<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
<PRE>echo 30 &gt; /proc/sys/net/ipv4/tcp_fin_timeout
</PRE>
</DIV></DIV></LI>
	<LI>Restart the networking component, for example by running
<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
<PRE>/etc/init.d/networking restart
</PRE>
</DIV></DIV>
<P>or</P>
<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
<PRE>service network restart
</PRE>
</DIV></DIV></LI>
</OL>



<H3><A name="FAQ-HowcanIaddotherlanguagetranslations%3F"></A>How can I add other language translations?</H3>
<P>First you need to specify your language name in config.message.languages configuration parameter. Then if you start the FTP server UI, you will see your language entry in the message panel. Translate messages and finally save your translated messages.</P>

<P>We are always interested in adding more translations to the official distribution of FtpServer. If you produce a translation and can contribute it back to the project, please create a <A href="https://issues.apache.org/jira/browse/FTPSERVER" rel="nofollow">new JIRA issue</A> so that we can add it to the core product.</P>

<H3><A name="FAQ-HowcanIsendbinarydatastoredinadatabasewhentheFTPServergetstheRETRcommand%3F"></A>How can I send binary data stored in a database when the FTP Server gets the RETR command?</H3>
<P>You can write your own ftplet to do this. The following code will clarify this.</P>

<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
    <SPAN class="code-keyword">public</SPAN> FtpletEnum onDownloadStart(FtpSession session, FtpRequest request,
            FtpReplyOutput response) <SPAN class="code-keyword">throws</SPAN> FtpException, IOException {

        <SPAN class="code-object">String</SPAN> requestedFile = request.getArgument();

        <SPAN class="code-comment">// get input stream from database - BLOB data
</SPAN>        InputStream in = getInputStreamFromDatabase(requestedFile);
        <SPAN class="code-keyword">if</SPAN> (in == <SPAN class="code-keyword">null</SPAN>) {
            response.write(<SPAN class="code-keyword">new</SPAN> DefaultFtpReply(550, <SPAN class="code-quote">&quot;Cannot find data &quot;</SPAN> + requestedFile));
            <SPAN class="code-keyword">return</SPAN> FtpletEnum.RET_SKIP;
        }

        <SPAN class="code-comment">// open data connection
</SPAN>        DataConnection out = <SPAN class="code-keyword">null</SPAN>;
        response.write(<SPAN class="code-keyword">new</SPAN> DefaultFtpReply(150, <SPAN class="code-quote">&quot;Getting data connection.&quot;</SPAN>));
        <SPAN class="code-keyword">try</SPAN> {
            out = session.getDataConnection().openConnection();
        } <SPAN class="code-keyword">catch</SPAN> (Exception ex) {
        }
        <SPAN class="code-keyword">if</SPAN> (out == <SPAN class="code-keyword">null</SPAN>) {
            response.write(<SPAN class="code-keyword">new</SPAN> DefaultFtpReply(425, <SPAN class="code-quote">&quot;Cannot open data connection.&quot;</SPAN>));
            <SPAN class="code-keyword">return</SPAN> FtpletEnum.RET_SKIP;
        }

        <SPAN class="code-comment">// transfer data
</SPAN>        <SPAN class="code-keyword">try</SPAN> {
            out.transferToClient(in);
            response.write(<SPAN class="code-keyword">new</SPAN> DefaultFtpReply(226, <SPAN class="code-quote">&quot;Data transfer okay.&quot;</SPAN>));
        } <SPAN class="code-keyword">catch</SPAN> (Exception ex) {
            response.write(<SPAN class="code-keyword">new</SPAN> DefaultFtpReply(551, <SPAN class="code-quote">&quot;Data transfer failed.&quot;</SPAN>));
        } <SPAN class="code-keyword">finally</SPAN> {
            session.getDataConnection().closeDataConnection();
            in.close();
        }
        <SPAN class="code-keyword">return</SPAN> FtpletEnum.RET_SKIP;
    }
</PRE>
</DIV></DIV>

<H3><A name="FAQ-WhyIamgettingClassNotFoundExceptionwhenIamtryingtousedatabasebasedusermanager%3F"></A>Why I am getting ClassNotFoundException when I am trying to use database based user manager?</H3>

<P>JDBC driver Jar file should be in CLASSPATH or it has to be copied in the INSTALL_DIR/common/lib directory. Did you specify fully qualified JDBC driver class name in                         config.user-manager.jdbc-driver configuration parameter?</P>

<H3><A name="FAQ-IhaveupdatedtheJDKversion.AfterthattheLDAPusermanagerisnotworking."></A>I have updated the JDK version. After that the LDAP user manager is not working.</H3>

<P>LDAP based user manager stores the user object in LDAP. This binary format is JDK specific.</P>

                </DIV>
  
              </DIV>
            </TD>
          </TR>
        </TABLE>
        <DIV class="footer" style="text-align: center">
          Copyright &copy; 2004-2008, <A href="http://www.apache.org/">The Apache Software Foundation</A>
        </DIV>
      </DIV>
    </DIV>
  </BODY>
</HTML>
